<template>
    <el-dialog 
        :visible.sync="isVisible"
        title="开奖设置" 
        :close-on-click-modal='false'
        :close-on-press-escape='false'
        :modal-append-to-body="false"
        @close="closeDialog">
        <div class="table_container">
		<search-record  @searchList="getData" @onBatchDelMoney="onBatchDelMoney"></search-record>
          
		  <el-table
			:data="tableData"
			@selection-change="handleSelectionChange"
			style="width: 100%"
			align='center'
		  >
			<el-table-column
			    type="selection"
			    align='center'
			    width="60">
			</el-table-column>
			 <el-table-column
				  prop="order_sn"
				  label="订单编号"
				  align='center'
				  width="100">
			  </el-table-column>
			   <el-table-column
				  prop="order_amount"
				  label="订单金额"
				  align='center'
				  >
			  </el-table-column>
			  <el-table-column
				  prop="buy_num"
				  label="订单数量"
				  align='center'
				  >
			  </el-table-column>
			  <el-table-column
				  prop="mobile"
				  label="下单手机号"
				  align='center'
				  >
			  </el-table-column>
			   <!-- <el-table-column
				  prop="下单手机号"
				  label="邀请人数"
				  align='center'
				  >
			  </el-table-column> -->
			  <el-table-column
				  prop="buy_num"
				  label="下单次数"
				  align='center'
				  >
			  </el-table-column>
			   <el-table-column
				  prop="prize_num"
				  label="中奖次数"
				  align='center'
				  >
			  </el-table-column>
			  <el-table-column
				  prop="register_time"
				  label="注册时间"
				  align='center'
				  >
			  </el-table-column>
			   <el-table-column
				  prop="add_time"
				  label="下单时间"
				  align='center'
				  >
			  </el-table-column>
		</el-table>
		<pagination 
			:pageTotal="pageTotal" 
			@handleCurrentChange="handleCurrentChange" 
			@handleSizeChange="handleSizeChange">
		</pagination>
        </div>
    </el-dialog>
</template>

<script>
   import { getOrderList, createPrize } from "@/api/goods";
   import SearchRecord from "./searchRecord";
   import Pagination from "@/components/pagination";
   import AreaJson from "@/assets/datas/area.json"

  export default {
      name:'addFundDialogs',
	  components:{
		  SearchRecord,
		  Pagination
	  },
      data(){
          return {
			multipleSelection: [],
            pageTotal:0,
			incomePayData:{
			    page:1,
			    pageSize:10,
			},
            isVisible: this.isShow,
		    tableData: [],
            dialog: {
                width:'680px',
                formLabelWidth:'120px'
            }
          }
      },
      props:{
          isShow:Boolean,
          dialogRow:Object
      },
      
      mounted(){
		  this.getData();
      },
      methods:{
		  handleSelectionChange(val) {
			  this.multipleSelection = val;
		  },
		  getData() {
			  let param = Object.assign({goodsId: this.dialogRow.id},this.incomePayData);
			  getOrderList(param).then(res => {
				  console.log(res);
				this.tableData = res.data.list;
				this.pageTotal = res.data.total;
			  })
		  },
          closeDialog(){
              this.$emit('closeDialog');
          },
		  onBatchDelMoney() {
			  console.log(222);
			  let param = {
				  goodsId: this.dialogRow.id,
				  orderIds: ''
			  }
			  this.multipleSelection.map((item,index) => {
				  param.orderIds = param.orderIds + (index?(',' + item.id):item.id);
			  })
			  createPrize(param).then(res => {
				  this.$message({
					message: '操作成功',
					type: 'success'
				})
			  })
			//   console.log(this.multipleSelection);
		  },
		  // 上下分页
		  handleCurrentChange(val){
		      this.incomePayData.page = val;
		      this.getData()
		  },
		  // 每页显示多少条
		  handleSizeChange(val){
		      this.incomePayData.pageSize = val;
		      this.getData()
		  },
          
      }
  }
</script>

<style lang="less" scoped>
	.table_container{
	    padding: 10px;
	    background: #fff;
	    border-radius: 2px;
	}
    .search_container{
        margin-bottom: 20px;
    }
    .btnRight{
        float: right;
        margin-right: 0px !important;
    }
    .searchArea{
        background:rgba(255,255,255,1);
        border-radius:2px;
        padding: 18px 18px 0;
    }
</style>
